package com.demo.designmode.test.clonedemo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

//浅克隆
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PersonShallow1 implements Cloneable{
    
    private String nickname;
    private Address address;
    
    @Override
    protected Object clone() throws CloneNotSupportedException {
    	return super.clone();
    }
    
    public static void main(String[] args) {
        
        Address address = new Address("辽源市");
        PersonShallow1 person= new PersonShallow1("李吴哲",address);
        
        try {
            PersonShallow1 clone = (PersonShallow1) person.clone();
            System.out.println(person == clone);
            System.out.println(person.getClass() == clone.getClass());
            System.out.println(person.getAddress() == clone.getAddress());
            System.out.println(person.getAddress().getClass() == clone.getAddress().getClass());
            System.out.println(person.getClass());

        } catch (CloneNotSupportedException e) {
        	e.printStackTrace();
        }
    }


}